﻿<controls:AlternativePage
    x:Class="WinRTXamlToolkit.Sample.Views.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:WinRTXamlToolkit.Controls"
    xmlns:common="using:WinRTXamlToolkit.Common"
    xmlns:views="using:WinRTXamlToolkit.Sample.Views"
    mc:Ignorable="d"
    DataContext="{Binding MainPage, Source={StaticResource Locator}}"
    NavigationCacheMode="Required">
    <controls:AlternativePage.Resources>
        <common:ImplicitStyleSelector
            x:Key="SampleLinkContainerStyleSelector">
            <Style
                x:Key="SampleButtonViewModel"
                TargetType="GridViewItem">
                <Setter
                    Property="HorizontalAlignment"
                    Value="Stretch" />
                <Setter
                    Property="HorizontalContentAlignment"
                    Value="Stretch" />
                <Setter
                    Property="VerticalContentAlignment"
                    Value="Stretch" />
                <Setter
                    Property="Width"
                    Value="400" />
                <Setter
                    Property="Height"
                    Value="65" />
            </Style>
            <Style
                x:Key="SampleGroupViewModel"
                TargetType="GridViewItem">
                <Setter
                    Property="HorizontalAlignment"
                    Value="Stretch" />
                <Setter
                    Property="HorizontalContentAlignment"
                    Value="Stretch" />
                <Setter
                    Property="VerticalContentAlignment"
                    Value="Stretch" />
                <Setter
                    Property="Width"
                    Value="400" />
                <Setter
                    Property="Height"
                    Value="65" />
                <Setter
                    Property="Background"
                    Value="#FF00A000" />
            </Style>
        </common:ImplicitStyleSelector>
        <common:ImplicitDataTemplateSelector
            x:Key="SampleLinkDataTemplateSelector">
            <DataTemplate
                x:Key="SampleButtonViewModel">
                <Button
                    Content="{Binding Caption}"
                    Command="{Binding Command}"
                    IsTabStop="False"
                    HorizontalAlignment="Stretch"
                    Style="{StaticResource TextButtonStyle}"
                    VerticalAlignment="Stretch"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Center"
                    Padding="16,-3,3,10"/>
            </DataTemplate>
            <DataTemplate
                x:Key="SampleGroupViewModel">
                <Button
                    Content="{Binding Caption}"
                    Command="{Binding Command}"
                    IsTabStop="False"
                    Foreground="White"
                    FontWeight="Bold"
                    HorizontalAlignment="Stretch"
                    Style="{StaticResource TextButtonStyle}"
                    VerticalAlignment="Stretch"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Center"
                    Padding="16,-3,3,10"/>
            </DataTemplate>
        </common:ImplicitDataTemplateSelector>
    </controls:AlternativePage.Resources>
    <Grid
        Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition
                Height="140" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                Width="120" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Button
            x:Name="ExitButton"
            Click="OnExitButtonClick"
            Margin="10,47,0,0"
            AutomationProperties.Name=""
            Style="{StaticResource NoAppBarButtonStyle}" />
        <TextBlock
            Grid.Column="1"
            Text="WinRT XAML Toolkit Tests"
            VerticalAlignment="Top"
            LineHeight="120"
            Style="{StaticResource PageHeaderTextStyle}">
            <TextBlock.RenderTransform>
                <TranslateTransform/>
            </TextBlock.RenderTransform>
        </TextBlock>

        <GridView
            x:Name="ButtonsGridView"
            Grid.Row="1"
            Grid.Column="1"
            HorizontalAlignment="Left"
            SelectionMode="None"
            IsItemClickEnabled="True"
            ItemClick="ButtonsGridView_OnItemClick"
            KeyDown="ButtonsGridView_OnKeyDown"
            ItemsSource="{Binding SampleGroups}"
            ItemContainerStyleSelector="{StaticResource SampleLinkContainerStyleSelector}"
            ItemTemplateSelector="{StaticResource SampleLinkDataTemplateSelector}">
            <GridView.ItemContainerTransitions>
                <TransitionCollection>
                    <RepositionThemeTransition />
                </TransitionCollection>
            </GridView.ItemContainerTransitions>
        </GridView>
    </Grid>
</controls:AlternativePage>
